/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bluetoothserver.dataStore;

/**
 *
 * @author Philip
 */
public class Question {
    private String question;
    private int type;
    private String[] answers;
    private int correct;
    private int nfl;

    public Question(String t,int ty,String[] an,int c){
        question = t;
        type = ty;
        answers = an;
        nfl = 0;
        correct = c;
    }

    public Question(){
        answers = new String[6];
        nfl = 0;
    }
    
    public void setQuestion(String q){
        question = q;
    }
    
    public String getQuestion(){
        return question;
    }
    
    public void setType(int i){
        type = i;
    }
    
    public int getType(){
        return type;
    }
    
    public void setAnswers(String[] a){
        nfl = 0;
        for(int i = 0;i < a.length;i++){
            answers[nfl] = a[i];
            nfl++;
        }
    }
    
    public String[] getAnswers(){
        return answers;
    }

    
    public void addAnswer(String a){
        if(nfl < 6){
            answers[nfl] = a;
            nfl++;
        }
    }
    
    public void addAnswer(String a, int p){
        if(p < 7){
            p--;
            for(int i = nfl; i > p;i--){
                answers[i-1] = answers[i];
            }
            answers[p] = a;
            nfl++;
        }
    }
    
    public void removeAnswer(String a){
        for(int i = 0;i < nfl;i++){
            if(answers[i].compareTo(a)==0){
                this.removeAnswer(i);
            }
        }
    }
    
    public void removeAnswer(int p){
        if(p < 7){
            for(int i = p;i < nfl; i++){
                answers[i] = answers[i+1];
            }       
            nfl--;
            answers[nfl] = null;
        }
    }

    public void setCorrectAnswer(int i){
        correct = i;
    }

    public int getCorrectAnswer(){
        return correct;
    }


}
